package com.bingo.sds.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bingo.framework.util.ResultTools;
import com.bingo.sds.entity.Example;
import com.bingo.sds.repository.ExampleRepository;


@RequestMapping(value="/example")
@Controller
public class ExampleController {
	@Autowired
	private ExampleRepository repository;
	
	@RequestMapping(value="/saveTest")
	@ResponseBody
	public String saveTest() {
		Long idStart = new Date().getTime();
		for(int i=0; i<5; i++) {
			Example ex = new Example();
			ex.setId("ID" + (idStart + i));
			ex.setName("name"+i);
			repository.save(ex);
		}
		
		return ResultTools.successResult("5 records saved");
	}
}
